PART 3 – Editing the Code

The last part of this project involves editing the code of the generated ABAP/4 BDC program.  This program needs to upload the files the legacy programmer has provided you, as well as code any special logic.  To finish the program, you will need to create an internal table that will store all the values that need to be populated in the Vendor Master Data table (LFA1).  You will need to setup a Parameters statement to accept the import files.  Finally, you will need to write special logic to get the desired output.

 

 

Table

Description

LFA1

Vendor Master Data

RLGRAP

Structure used when uploading/downloading file formats

 

parameters: p_file like rlgrap-filename.

 

 

data: begin of itab occurs 10,

vendor like lfa1-lifnr,

name like lfa1-name1,

city like lfa1-ort01,

zip  like lfa1-pstlz,

end of itab.

 

 

 

data: wf_record(80),

wf_split type x value '09'.   "this represents a tab in a file   

 

 

 

perform get_data.

 

 

 

open dataset p_file in text mode.

 

 

do.

read dataset p_file into wf_record.

 

if sy-subrc ne 0.

exit.

else.

split wf_record at wf_split into itab-vendor itab-name itab-city

itab-zip.

append itab.

 

endif.

enddo.

 

 

 

 

 

close dataset p_file.

 

 

loop at itab.  "start looping through all all records from file

 

 

 

 

BDC Field Name

Original Value

Change to Value

RF02K-LIFNR

ZBDCTESTXX

itab-vendor.

BDC_CURSOR

RF02K-KTOKK

Refer to If statement below

LFA1-NAME1

BDC Test Borquez XX

itab-name.

LFA1-SORTL

BDCTE

itab-name+0(5).

LFA1-ORT01

Beverly Hills

itab-city.

LFA1-PSTLZ

90211

itab-zip.

 

 

if itab-vendor = space.

perform bdc_field       using 'RF02K-KTOKK'

'kred'.

else.

perform bdc_field       using 'RF02K-KTOKK'

'LIEF'.

endif.

 

 

 

 

perform bdc_transaction using 'MK01'.

 

 

refresh bdcdata. " clear all records in table, not just header record

 

 

 

 

 

 

 

 

 

 

 

 

 

 

If you are successful with executing the program, you could expect the following screen:

 

 


 

 

 

 


 

 

 

The system will now walk you through the batch process for your text file.  Notice the values that are given to each field during this walk through.  In the future, you may run this process in ‘Background’ mode if you are importing thousands of records, rather than just a few.  This is a good test to see if your program can successfully run the text file.

 

When the batch process completes, you will see the following window:

 

 


 

You will see the results from your successful batch input:

 

 

That’s all folks!

 

 

 

 

 

 

 

 

Ir a la página principal de SAP ABAP en castellano